// 引入react
import * as React from 'react';
import {StyleSheet, View, Text, Dimensions, ScrollView} from 'react-native';
import {SafeAreaView} from 'react-native-safe-area-context';
import {HeaderTitle} from '../../../componet/settingComponent/HeaderTitle';
import AllStyle from '../../../style';
import Icon from 'react-native-vector-icons/AntDesign';
import {TabItem} from '../../../componet/settingComponent/TabItem';
import {MyStatistics} from './MyStatistics';
import {connect} from 'react-redux';
import {TeamStatistics} from './TeamStatistics';
import {isAuth} from '../../../storage/permissions';

/**
 * @Description:
 * @author TangYong
 * @date 2023/2/6
 */
 class StatisticsInfos extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            choseVal: true,
            statisticsInfos:false,
        };
    }

    //生命周期：组件挂载后
    async componentDidMount() {
        let statisticsInfos= await isAuth('ad:statisticsInfos:main')
        this.setState({statisticsInfos})
        //console.log("....",this.props)
    }

    //方法
    setChoseVal = (val) => {
        this.setState({choseVal: val});
    };

    //DOM
    render() {

        return (

            <SafeAreaView edges={['top', 'left', 'right']} style={{flex: 1, backgroundColor: '#ffffff'}}>
                <View style={AllStyle.container}>
                    <View style={style.btLine}>
                        <View style={style.con_top}>
                            <Text style={style.title}>统计</Text>
                        </View>
                        {this.state.statisticsInfos&&
                        <TabItem ItemOne={'我的统计'} ItemTwo={'团队统计'} setVal={
                            (val) => {
                                this.setChoseVal(val);
                            }} choseVal={this.state.choseVal}></TabItem>}
                    </View>

                    <ScrollView style={[AllStyle.padding15]}>
                        {/*<View style={ this.state.choseVal==false&&{display: 'none'}}>*/}
                        <View>
                            { this.state.choseVal&&
                            <MyStatistics navigation={this.props.navigation}></MyStatistics>}
                        </View>
                        {/*<View style={ this.state.choseVal==true&&{display: 'none'}}>*/}

                        <View>
                            { this.state.choseVal==false&&
                            <TeamStatistics navigation={this.props.navigation}></TeamStatistics>}
                        </View>


                        <View style={{height:15}}>

                        </View>
                    </ScrollView>
                </View>
            </SafeAreaView>
        );
    }

}

const width = Dimensions.get('window').width;
const style = StyleSheet.create({
    //样式
    con_top: {
        backgroundColor: '#fff',
        // borderBottomWidth: 1,
        // borderStyle: 'solid',
        // borderColor: '#E8E8EA',
        width: width,
        padding: '2%',
        flexDirection: 'row',
    },
    title: {
        paddingLeft:10,
        fontSize: 19,
        fontWeight:'bold'
    },
    btLine:{
        marginBottom: StyleSheet.hairlineWidth,

        // 【方法一】用border做分割线
        borderBottomColor: '#EBEDED',
        borderBottomWidth: StyleSheet.hairlineWidth,
    },
});


export  default StatisticsInfos
